/**
 * 
 */
package com.kingre.et.action;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.context.SecurityContextHolder;

import com.kingre.et.model.School;
import com.kingre.et.model.User;
import com.kingre.et.service.IConsultService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Jingui Yu
 *
 */
public class ConsultAction extends ActionSupport {
    private static final long serialVersionUID = -6950088741317549913L;
    private static final Logger logger = Logger.getLogger(ConsultAction.class);
    @Autowired
    private IConsultService consultService;
    private Integer exportUserId;
    private String userTel;
    private String telMobile;
    private String consultDate;
    private School school;
    
    public List<User> exports;
    
    public String input(){
        User currentUser = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        exports = consultService.getExperts();
        school = consultService.getSchoolByUserId(currentUser.getId());
        return INPUT;
    }
    
    public String schoolConsult(){
        User currentUser = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        consultService.consultSchool(currentUser.getId(), telMobile);
        this.addFieldError("dd", this.getText("consult.ok"));
        return input();
    }
    public String expertConsult(){
        User currentUser = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        consultService.consultExpert(currentUser.getId(), exportUserId, userTel);
        this.addFieldError("dd", this.getText("consult.ok"));
        return input();
    }

    public Integer getExportUserId() {
        return exportUserId;
    }

    public void setExportUserId(Integer exportUserId) {
        this.exportUserId = exportUserId;
    }

    public String getUserTel() {
        return userTel;
    }

    public void setUserTel(String userTel) {
        this.userTel = userTel;
    }

    public String getConsultDate() {
        return consultDate;
    }

    public void setConsultDate(String consultDate) {
        this.consultDate = consultDate;
    }

    public List<User> getExports() {
        return exports;
    }

    public void setExports(List<User> exports) {
        this.exports = exports;
    }

    public School getSchool() {
        return school;
    }

    public void setSchool(School school) {
        this.school = school;
    }

    public String getTelMobile() {
        return telMobile;
    }

    public void setTelMobile(String telMobile) {
        this.telMobile = telMobile;
    }
    
}
